package com.aos.erp.fs.model;

import com.aos.erp.fs.enums.FileStatus;
import com.aos.erp.fs.enums.FileUriType;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;

@Getter
@Setter
@ToString
@TableName("t_sys_file")
public class SysFile {

    @ApiModelProperty("文件ID，全局唯一")
    @TableId(value = "ID", type = IdType.INPUT)
    private long id = 0;

    @ApiModelProperty("所属应用ID")
    @TableField("app_id")
    private String appId;

    @ApiModelProperty("所属用户ID")
    @TableField("user_id")
    private String userId;

    @ApiModelProperty("资源类型:1 ali oss")
    @TableField("uri_type")
    private FileUriType uriType = FileUriType.local;

    @ApiModelProperty("资源地址")
    @TableField("uri_src")
    private String uriSrc;

    @ApiModelProperty("文件名称")
    @TableField("name")
    private String name;

    @ApiModelProperty("文件大小")
    @TableField("size")
    private long size;

    @ApiModelProperty("文件类型")
    @TableField("type")
    private String type;


    @ApiModelProperty("文件类型")
    @TableField("content_type")
    private String contentType;

    @ApiModelProperty("创建时间")
    @TableField("create_time")
    private Date createTime;

    @ApiModelProperty("过期时间，若文件可删除，允许在过期后删除文件")
    @TableField("timeout_time")
    private Date timeOutTime;

    @ApiModelProperty("状态:0正常 1 删除")
    @TableField("status")
    private FileStatus status = FileStatus.normal;


    public String getStatusName() {
        return this.status.getDesc();
    }

    public String getUriTypeName() {
        return this.uriType.getDesc();
    }
}
